Software and hardware emulation system

ABSTRACT

A method to emulate a system represented by one or more of hardware portions and software portions is described. The method comprises determining whether a subset of the one or more hardware portions and software portions have been tested, and identifying whether the system has performed to a specification based on the testing. The method further comprising, when the system has not performed to the specification, determining one or more of the hardware and software portions to update for retesting.

RELATED CASES

The present invention is a continuation-in-part of of U.S. patent application Ser. No. 13/844,110 filed on Mar. 15, 2013, which will be issuing as U.S. Pat. No. 9,317,399, on Apr. 19, 2016, which claims priority to U.S. Provisional Application No. 61/706,816 filed on Sep. 28, 2012.

The present application is additionally a continuation-in-part of U.S. patent application Ser. No. 15/069,841, filed on Mar. 14, 2016, which is a continuation of U.S. patent application Ser. No. 13/901,462, filed on May 23, 2013, which is now U.S. Pat. No. 9,285,796, issuing on Mar. 15, 2016, which is a divisional application of U.S. patent application Ser. No. 12/204,777, filed on Sep. 4, 2008, which is now U.S. Pat. No. 8,453,084, issued on May 28, 2013.

All of the above patents and applications are incorporated by reference in their entirety.

BACKGROUND

Workflow management of software development typically involves coordinating the development of the code with the testing of code. FIG. 1 is an illustrative drawing representing a typical software development and testing cycle 100. The development and testing of complex software code typically is an iterative process. Code 102 ordinarily is subjected to tests while it is still in development. New features are added while software bugs/errors and vulnerabilities are corrected. The development and testing cycle repeats until the code is determined to be sufficiently developed and tested.

More particularly, for example, one or more software architects 104 may contribute to a design of a system architecture that is to be implemented using computer program code. A software development team 106 develops software code features 102 to implement the architecture and also may work in concert with a test engineering team to develop tests 108 for the new code and also to test the existing code for regressions, such as unintended changes to the previously existing behavior, for example. The developers 106 and test engineers 110 ordinarily collaborate in fixing tests, fixing code (e.g., implementing new or additional intended behavior) and in fixing bugs 112 (e.g., deviations from the intended behavior). Development managers 114 manage the overall process and determine when code features are adequately developed, bugs have been sufficiently eliminated and risks are well enough understood to release the code for quality assurance 116.

Dynamic analysis and static analysis are two different techniques used in the automated testing of software code. Dynamic analysis is performed by observing the behavior of code while the code executes on a machine. Static analysis is performed on static code i.e., code that is not running during the analysis process.

Dynamic analysis evaluates runtime behavior of computer code. Instrumentation code is inserted into the code-under-test. The instrumentation code captures runtime information generated in the course of execution of the code for use in observing and evaluating the dynamic, i.e. runtime execution, behavior of the code. U.S. Pat. No. 5,335,344, invented by Hastings, discloses an example of some known software code instrumentation and dynamic analysis techniques. The execution of code during dynamic analysis is driven by tests, which are artifacts that provide input parameters to the system undergoing the analysis. Additionally, tests verify the intended behavior by comparing the output from the system under test with the expected output recorded as part of each test case.

Static analysis can be used to detect kinds of errors that are often missed when using dynamic analysis techniques alone. For example, static analysis may detect an illegal operation that is contained in a rarely traversed or otherwise hard-to-test conditional branch code path that is rarely visited during operation of the software, and that therefore, easily could go undetected during dynamic analysis. Static analysis ordinarily involves use of a variety of different static analysis programs/software tools often referred to as ‘checkers’ to evaluate code paths to identify different kinds of vulnerabilities and/or errors. For example, checkers can be used to detect syntax errors, functions without return values, variables that have been declared but not used, inadvisable automatic type conversions, tainted data, integer overflows, global-variable inconsistencies, problems associated with using modules (e.g., missing or invalid modules or input/export mismatches), to name just a few.

Dynamic analysis and static analysis techniques have been developed that utilize information generated during a build process to identify the code that is to be subjected to analysis. Modern software typically is developed using a modular approach. Teams of programmers may work on different modules or portions of the software. Consequently, source code, compilers, and ancillary software components often are distributed across many different directories and systems. As a result of this complexity, software developers typically use build management utilities such as the “make” program to assist in the process of building executable code.

Dynamic analysis and static analysis can take advantage of the build process by intercepting information about the code generated during a build process and using the information to identify the code to be analyzed. During a typical software development process, source code is compiled to produce an executable script in a high-level programming language, byte code that needs to be further interpreted by an interpreted program, and/or executable binary code that runs directly on the CPU. Different portions of the software may be written using different programming languages that require the use of different compilers, for example. Moreover, different compilers may be used to compile different portions of the source code, even when all of the code is written in the same language. For example, different compilers may produce executable code that runs on computer systems with different microprocessors. A ‘build’ process, which involves identifying the source code files associated with a program and establishing appropriate directory locations, compiler names, and other compilation settings involves many steps, and software developers typically automate such a build process using what typically is referred to as a build program. Both dynamic analysis and static analysis processes may leverage information about source code that is made available during the build process by intercepting information that identifies the code to be statically analyzed. Commonly owned U.S. Pat. No. 7,340,726 invented by Chelf et al. describes examples of some known static analysis techniques that leverage information about code made available during a build process.

Workflow management of the development and testing of software systems that may involve millions of lines of code developed at different times by different individuals is a complex challenge. Keeping code development on schedule while ensuring that the code is adequately tested requires maintaining an up to date record of what code requires testing as the code changes while it is in development. Workflow management often is especially difficult because the code development cycle is interleaved with dynamic and static testing. Keeping track throughout the development and testing cycle of what has been accomplished, what needs to be done and who needs to do what and when is an important but difficult responsibility.

SUMMARY

In one aspect, a method is provided to evaluate testing of computer program code. The method includes configuring a computer to automatically determine whether a specific portion of the code has been adequately tested.

In another aspect, a method or an article of manufacture can be provided to evaluate tests of computer program code. The method includes configuring a computer to produce a code filter to indicate one or more respective portions of the computer program code to respectively either omit from or to include in a determination of adequacy of test results. Test results are compared with the computer program code, with the one or more respective portions filtered using the code filter to respectively either omit the respective portions from or to include the respective portions in the determination as indicated by the code filter.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is an illustrative drawing representing a typical software development and testing cycle.

FIG. 2 is an illustrative block diagram of a system to implement observation and analysis of source-code-under-test in accordance with some embodiments.

FIG. 3 is an illustrative diagram representing a code filter generation module to generate a code filter structure, which is stored in a computer readable storage device in accordance with some embodiments.

FIG. 4A is an illustrative drawing representing a first user interface display for use in entering information in a test policy specification that includes code filter related information for use by the code filter generation module to generate the code filter in accordance with some embodiments.

FIG. 4B is an illustrative drawing representing a second user interface display for use in entering information in a test policy specification that includes specific code portion information for use in evaluating adequacy of evaluation of code under-test as represented by the runtime observations in accordance with some embodiments.

FIG. 5 is an illustrative flow diagram representing details of a process performed using a computer configured to implement the code filter generation module of FIG. 3 in accordance with some embodiments.

FIG. 6 is an illustrative drawing representing a code filter structure generated in accordance with the process of FIG. 5 and stored in a computer readable device in accordance with some embodiments.

FIG. 7 is an illustrative diagram representing operation of an evaluate module to evaluate the code of the example filtered AST of FIG. 6 in accordance with some embodiments.

FIG. 8 is an illustrative flow diagram representing details of a process performed using a computer configured to implement the evaluate module of FIG. 7 in accordance with some embodiments.

FIG. 9 is illustrative drawing showing example source code from within the SCM of FIG. 2 that is annotated with information concerning its provenance.

FIGS. 10A-10D are illustrative drawings showing the example source code annotated to indicate information generated by the test capture module and stored in the dynamic runtime observations module of FIG. 2.

FIGS. 11A-11F are illustrative drawings showing the example source code annotated to indicate checker tests performed by the static analysis module of FIGS. 2-3 in accordance with some embodiments.

FIG. 12 is an illustrative drawing showing two example test policies in accordance with some embodiments.

FIG. 13 is an illustrative graph representing in conceptual terms a relationship between percentage code tested versus effort to develop tests to test the code.

FIG. 14 shows a diagrammatic representation of a machine in the example form of a computer system within which a set of instructions, for causing the machine to perform any one or more of the methodologies discussed herein, may be executed.

DESCRIPTION OF EMBODIMENTS

The following description is presented to enable any person skilled in the art to create and use a computer system configuration and related method and article of manufacture to determine portions of computer program code that are to be tested and to use the determination as a basis to evaluate adequacy of the testing the computer program code. Various modifications to the embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments and applications without departing from the spirit and scope of the invention. Moreover, in the following description, numerous details are set forth for the purpose of explanation. However, one of ordinary skill in the art will realize that the invention might be practiced without the use of these specific details. In other instances, well-known data structures and processes are shown in block diagram form in order not to obscure the description of the invention with unnecessary detail. Identical reference numerals may be used to represent different views of the same item in different drawings. Flow diagrams in drawings referenced below are used to represent processes. A computer system is configured to perform these processes. The flow diagrams include modules that represent the configuration of a computer system according to computer program code to perform the acts described with reference to these modules. Thus, the present invention is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.

FIG. 2 is an illustrative block diagram of a system to implement observation and analysis of source-code-under-test in accordance with some embodiments. Source-code-under-test 202 is stored in a storage device 203. A build module 204 implements a build process that identifies and accesses source code files associated with the software code 202 to be tested. It will be appreciated that the source code 202 may comprise source code files stored in disparate locations and that often a build program is used to configure a computer to locate and identify the files so that they can be tested. More particularly, in some embodiments, a build program such as a ‘make’ utility automatically builds executable programs and libraries from source code by reading files often called ‘makefiles’ which specify how to derive the target program. A build interception module 206 configures a computer to intercept the source code files through the build module 204 and captures the identified source code 202 to be tested in a storage device 208. In some embodiments, the code-under-test is transformed for representation in an abstract syntax tree (AST) structure 210 in which many specifics of formatting and identifiers are removed from the source code 202, and the remaining code is organized in a tree structure suitable for automated static analysis of the code.

A static analysis module 212 implements a static analysis software tool to perform static analysis of the source code 202 represented by the AST structure 210 stored in the storage device 208. Performing static analysis may involve configuring a computer to run a variety of checkers on the source code to produce a corresponding variety of static analysis results. A checker is a program that analyzes the static code for some specific property or characteristic. A static analysis tool typically can run a large variety of different checkers. In some embodiments, the static analysis module 212 produces first static analysis results indicated by arrow 214 that identify defects and/or vulnerabilities in the source-code-under-test 202, which is represented by the AST structure 210. Indications of the defects and/or vulnerabilities, such as the kinds of defects and their locations in the source code 202, are stored in storage in a storage device 218. The static analysis module 212 produces second static analysis results indicated by arrow 220 useful to identify semantically-significant code behaviors, such as abnormal program termination, logically non-executable code and more. A source control management (SCM) module 250 comprises a database stored in a computer readable storage device that includes computer program source code and metadata information about modifications to the software, such as the kinds of changes (e.g., additions and/or subtractions of code), time frames in which changes were made, authors of the changes and locations of the changes in the source code 202. The SCM module 248 is coupled to provide the source code and associated metadata about the source modification history to a test analysis module 224, which is described more fully below.

An instrumentation module 230 configures a computer to compile and instrument the source code 202 that is intercepted by the build intercept module 206 and provides the instrumented executable code 232 for storage in a storage device 234. Dynamic (runtime) test code 235 is stored in a storage device 236. A test capture module 238 configures a computer to run the instrumented executable code 232 and to run the test code 235 to perform runtime tests on the instrumented code 232 to observe runtime behavior of the instrumented code 232, and to provide runtime observations 240 for storage in a storage device 242.

The test analysis module 224 configures a computer to evaluate sufficiency of testing of source-code-under-test 202 as a function of a source code modification history 246 and static analysis test results 220 specified in the test policy specification 254. The test analysis module 224 configures a computer as indicated by arrow 252 to access the test policy specification 254 stored in a storage device 256 that indicates the desired test coverage. As explained more fully below, in some embodiments the test policy specification 254 specifies the desired test coverage in terms of code history parameters and static analysis directives that indicate code portions to be excluded from test coverage and that indicate code portions to be included within test coverage. The test analysis module 224, further configures a computer, as indicated by arrow 220, to access the second static analysis results 220. The test analysis module 224 further configures a computer as indicated by arrow 226 to access the source code represented as an AST 210. The test analysis module 224 further configures a computer, as indicated by arrow 244, to access contents of the runtime observations 240. The test analysis module 224 further configures a computer, as indicated by arrow 246, to access contents of the source code modification history 248 stored in a storage device 250. The test analysis module 224 further configures a computer to produce output information indicated by arrow 270 that provides an indication of whether the dynamic observations meet test coverage requirements specified in the specification.

FIG. 3 is an illustrative diagram representing a code filter generation module 302 to generate a code filter structure 304, which is stored in a computer readable storage device (not shown), in accordance with some embodiments. The module 302 is a constituent of the test analysis module 224, which is indicated by dashed lines labeled 224. The code filter generation module 302 receives as input a test policy 254 as indicated by arrow 252, SCM information 248, as indicated by arrow 246, static analysis (STA) results as indicated by arrow 220, and an abstract syntax tree (AST) 210 as indicated by arrow 226 that represents the computer program code-under-test. The code filter generation module 302 generates the code filter information structure 304 in response to the received inputs. The code filter information structure 304 is a dynamically generated constituent of the test analysis module 224.

FIGS. 4A-4B are illustrative drawings representing information entered in the test policy specification 254 via a user interface display generated on a computer screen display for input to the test analysis module 224, and more particularly, to the code filter generation module 302 within the test analysis module 224 in accordance with some embodiments. FIG. 4A is an illustrative drawing representing a first user interface display 402 for use in entering information in a test policy specification 254 that includes code filter related information for use by the code filter generation module 302 to generate the code filter 304 in accordance with some embodiments. The illustrative first user interface display 402 comprises a plurality of fields arranged in a matrix of rows and columns. A first column 404 contains filter type fields that identify different filter types and a second column 406 contains filter value fields that indicate user-selected values for the different filter types. A first row 408 contains an SCM Include Range field 406 and a corresponding user-selected value to indicate a range of time and/or authors to be used to identify portions of the code-under-test to be included in evaluation of the runtime observations 240. A second row 410 contains an SCM Exclude Range field and a corresponding user-selected value to indicate a range of time and/or authors to be used to identify portions of the code-under-test to be excluded from evaluation of the runtime observations 240. A third row 412 contains an STA Include field and a corresponding user-selected value to indicate a STA results to be used to identify portions of the code-under-test to be included in evaluation of the runtime observations 240. A third row 414 contains an STA Exclude field and a corresponding user-selected value to indicate a STA results to be used to identify portions of the code under test to be exclude in evaluation of the runtime observations 240. Thus, it will be appreciated that in accordance with some embodiments, a user interface screen display is generated that that a user may use to indicate general portions of the code-under-test that are of interest for evaluation. In some embodiments, the user interface includes an input whereby a user may provide an indication as to which filter ought to take precedence in the event of a conflict between the filters, e.g., in the event that one filter indicates that certain code should be omitted but another filter indicates that that same code should be included.

FIG. 4B is an illustrative drawing representing a second user interface display 420 for use in entering information in a test policy specification 254 containing specific code portion information for use in evaluating adequacy of evaluation of code under-test as represented by the runtime observations 240 in accordance with some embodiments. The computer program code under test has different constituent portions, and different individual code folters can be specified for these different code portions. Different portions can be tested using different tests, and the different code filters can be used to zero in on specific code portions to determine whether testing has been adequate as to those specific code portions. The second user interface display 420 can be used to designate the specific portions of the code-under-test to be evaluated for adequacy of testing based upon the runtime observations 240. For example, in some embodiments, a user can enter information in the second user interface display 240 to indicate specific code portions to be tested such as: of lines of code; files, functions, branch conditions; conditional branch execution sequences; values of code variables; and sequence of code statements. Also, for example, specific portions to be tested may include branches within lines, branches within files, and lines within files. Moreover, specific code portions may include syntax constraints and code constraints, for example. The specific portions are contained in the AST 210, which is provided as an input to the test analysis module 224. Moreover, the specific code portion may include a range of one or more values that are to be tested for variables in the code. In accordance with some embodiments, in response to a user designating specific code portions to be included in or omitted from testing, corresponding code filters are created and stored in a computer readable storage device (not shown) for use in filtering the code of the AST 210 accordingly. Thus, specific code filters may be created to filter the code in the AST 210 based upon lines of code; files, functions, branch conditions; conditional branch execution sequences; values of code variables; and sequence of code statements for example. Therefore, it will be appreciated that in accordance with some embodiments, a user interface screen display is generated that that a user may use to indicate specific portions of the code-under-test that are of interest for evaluation.

FIG. 5 is an illustrative flow diagram representing details of a process 500 performed using a computer configured to implement the code filter generation module 302 of FIG. 3 in accordance with some embodiments. Module 502 configures a computer to use user-provided values associated with the SCM Include Range and/or SCM Exclude Range information within a test policy specification 254, specified using the first user interface display 402, in conjunction with the SCM 248, to identify and demarcate code as a function of time and/or author to include and/or omit from an evaluation of adequacy of testing indicated by the runtime observations 240. Stated differently, the SCM 248 correlates modifications (including creations, additions, deletions) of code within the code-under-test (which is represented by the AST 210) with the times and authors of those modifications. The user-provided SCM Include Range and/or SCM Exclude Range indicates times and/or authors of code modification to be used (or not used) in evaluating adequacy of the testing. The module 502 uses the user-provided time/author information in conjunction with the SCM 248 to identify code in the code-under-test to be used (or not used) to evaluate the adequacy of the testing indicated by the runtime observations 240.

Module 504 configures a computer to use user-provided values associated with the STA Include and/or STA Exclude information within a test policy specification 254, specified using the first user interface display 402, in conjunction with the results generated by one or more checkers of the static analysis (STA) tool 212, to identify and demarcate code to include in and/or omit from an evaluation of adequacy of testing indicated by the runtime observations 240. Stated differently, the STA tool 212 can identify and demarcate code from the code-under-test that should be excluded from testing even if it falls within a user-specified time and/or author range and can identify and demarcate code from the code-under-test for that should be included within testing even if it falls outside a user-specified time and/or author range.

FIG. 6 is an illustrative drawing representing a code filter structure generated in accordance with the process of FIG. 5 and stored in a computer readable device in accordance with some embodiments. The code filter structure 602 is associated in the storage with the AST 210, which corresponds to and represents the code-under-test, so as to define a filtered AST 210′. The term ‘filtered AST’ as used herein, refers to the AST 210 with the code filter structure 602 associated with it in storage. More specifically, the illustrative code filter structure 602 includes one or more example static analysis (STA) filter elements 604-610. The illustrative code filter structure 602 also includes one or more example source control management (SCM) filter elements 612 (only one shown). The illustrative code filter structure 602 also includes one or more example specific code portion filter elements 630 (only one shown). More particularly, each respective STA filter element 604-610 is associated with a respective portion (referred to herein as a ‘filtered portion’) of the code within the AST 210 that is to be either included in or excluded from a determination of adequacy of the dynamic test results represented by the runtime observations 242. Similarly, each of the one or more SCM filter elements 612 (only one shown) is associated with a respective portion (referred to herein as a ‘filtered portion’) of the code within the AST 210 that is to be either included in or excluded from a determination of adequacy of the dynamic test results represented by the runtime observations 242. Likewise, each of the one or more code portion filter elements 612 (only one shown) is associated with a respective specific code portion (referred to herein as a ‘filtered portion’) of the code within the AST 210 that is to be either included in or excluded from a determination of adequacy of the dynamic test results represented by the runtime observations 242.

It will be appreciated that in some instances an STA filter element, an SCM filter element and a specific code portion filter element may be associated in whole or in part with the same code within the AST 210. In accordance with some embodiments, when both an STA filter element and an SCM filter element overlap and are associated in whole or in part with the same code within the AST 210, the STA filter element takes precedence. As explained more fully below, in practice that means that when an STA filter element and an SCM filter element are associated with the same code of the AST 210, a filter operation corresponding to the STA element with respect to the overlapped code takes precedence over a filter operation corresponding to an SCM filter element with respect to the overlapped code.

Still referring to FIG. 6, the filtered AST 210′ includes many lines of code 614, 614F. Some of these lines are associated with the code filter structure 602 and some are not. In the illustrative example of FIG. 6, code that is filtered by either an STA filter element or an SCM filter element or a specific code portion filter element is labeled as 614F, and code that is not filtered by either an STA filter element or an SCM filter is labeled 614. More specifically, code that is associated with one of the STA filter elements is shown in FIG. 6 as being enclosed within one of the boxes labeled 604-610; code that is associated the SCM filter element 612 is shown in FIG. 6 as being enclosed within the box labeled 612; and code that is associated with a specific code portion filter is shown enclosed within box a labeled 630. Note that the same code may be impacted by more than one filter, and rules may be applied to define precedence among filters or to declare an error when two or more filters indicate competing filtering actions. In this illustrative example, the code associated with STA filter elements 606-610 also is associated with the SCM filter element 612. Thus, code labeled 614F is ‘filtered’, and code labeled 614 is not ‘filtered.

FIG. 7 is an illustrative diagram representing operation of an evaluate module 702 to evaluate the code of the example filtered AST 210’ of FIG. 6 in accordance with some embodiments. The evaluate module 702 is a constituent of the test analysis module 224, which is indicated by dashed lines labeled 224. Further, assume in this example that the test policy 254 includes user-indicated specific portions of the AST 210 that ought to be tested in order for the testing to be adequate.

FIG. 8 is an illustrative flow diagram representing details of a process 800 performed using a computer configured to implement the evaluate module 702 of FIG. 7 in accordance with some embodiments. Module 802 configures a computer to receive as input the runtime observations 240, the filtered AST 210′ and input from the test policy 254 indicating specific portions of the code-under-test that ought to be evaluated. Module 802 configures a computer to compare specific code portions of the filtered AST 210′ with the runtime observations 240. Module 804 configures a computer to determine test age based upon the comparison.

Referring again to FIG. 7 and also to FIG. 8, assume in this example, that STA filter 604 is an ‘include’ filter and that STA filter elements 606-610 are ‘exclude’ filter elements. Also, assume in this example that SCM filter 612 is an ‘include’ filter element. Also, assume that the runtime observations 240 include text lines 704. Thus, filtered code 614F1 associated with STA filter element 604 is designated by filter element 604 as included in tests. Since in this example, STA filter elements take precedence over SCM filter elements, filtered code 614F3, 614F5 and 614F7 associated respectively with STA filter elements 606, 608 and 610 are designated by those STA filter elements as excluded from tests. Finally, filtered code 614F2, 614F4, 614F6 and 614F8 are designated by SCM filter element 612 as included in testing. Unfiltered code 614 is not included in the tests.

In accordance with the process 800 of FIG. 8, the evaluate module 702 of FIG. 7, receives from the test policy 254 indications of specific portions of the code of the filtered AST 210′ that is included in tests that ought to be indicated in the runtime results 240 as having been tested. For example, the specific portions indicated may indicate particular lines of code from the code-under-test, and in response, the module 702/804 determines whether the text 704 within the runtime results 240 indicates that the particular lines of code have been tested adequately. The specific portions indicated may indicate specific branches conditional execution of code from the code-under-test, and in response, the module 702/804 determines whether the text 704 within the runtime results 240 indicates that the particular specific branches conditional execution have been tested adequately. The specific portions indicated may indicate specific conditional execution sequences of code from the code-under-test, and in response, the module 702/804 determines whether the text 704 within the runtime results 240 indicates that the particular specific conditional execution sequences have been tested adequately. The specific portions indicated may indicate specific values of code variables of code from the code-under-test, and in response, the module 702/804 determines whether the text 704 within the runtime results 240 indicates that the particular values of code variables of code statements have been tested adequately. The specific portions indicated may indicate specific sequence of code statements of code from the code-under-test, and in response, the module 702/804 determines whether the text 704 within the runtime results 240 indicates that the particular specific sequence of code statements have been tested adequately.

EXAMPLES Examples—Source Control Management (SCM) Repository

FIG. 9 is illustrative drawing showing example source code from within the SCM 248 of FIG. 2 that is annotated with information concerning its provenance. The metadata in the form of annotations that indicate code ownership (e.g., originally written by ‘Albert Miller’), change sets (e.g., additions by ‘Peter Pan’ and changed by ‘Dave Fastcode’) and code age (e.g., see dates). The SCM provides both the code and historical information about code development that can be used to specify what code is to be tested.

For example, test policy specification 254 can be created to indicate that all code created in a time range defined as after Jul. 15, 2012 is to be tested. Alternatively, for example, in some embodiments a test policy specification 254 can be created to indicate a second history parameter that specifies a code range that includes code generated by Dave Fastcode between Mar. 15, 2012 and Aug. 15, 2012 is to be tested. Thus, the SCM 248 includes metadata about the code (e.g., authors and dates) that can be used to create one or more SCM filter elements to indicate what portion of the code is to be tested and/or what portion is to not be tested.

Examples—Dynamic Analysis

FIGS. 10A-10D are illustrative drawings showing the example source code annotated to indicate information generated by the test capture module 238 and stored in the runtime observations module 240 of FIG. 2. The instrumentation of the code enables the capture module 238 to monitor test execution while the code is running to observe what tests are being performed on which portions of code. FIG. 10A illustrates an example of monitoring of overall test coverage. FIGS. 10B-10D illustrate specific examples of particular tests.

FIG. 10A is an illustrative drawing of the example code with annotations to indicate portions of the code that have been tested using each of Test_name1.c, Test_name2.c, etc. As explained above, module 230 instruments the code. The instrumentation of the code is used to monitor code coverage of Test_name1.c, Test_name2.c, etc. Portions of the example code that are not annotated to indicate that these tests have been performed have not been tested using these tests. In this example, test capture module 238 causes an indication to be stored in the runtime observations module 240 that the following specific portions of the code-under-test have been tested: lines 10-24, 27, 30-31 and 35-41. Moreover, the runtime observations indicate that these specific portions were tested using tests Test_name1.c, Test_name2.c, etc.

FIG. 10B is an illustrative drawing of the example code with annotations to indicate that a particular variable has assumed certain values in the course of dynamic testing. In this example, module 230 instruments the example code to observe values assigned to variable “c” during testing. The test capture module 238 causes values that have been assigned to variable “c” during testing of the code to be stored in the runtime observations module 240 In this example, test capture module 238 causes an indication to be stored in the runtime observations module 240 that the following specific portion of the code-under-test have been tested: variable “c” has assumed the values {0, 1, 3, 5, 7, 23, 34}.

FIG. 10C is an illustrative drawing of the example code with annotations to indicate that a particular call function has been called some number of times in the course of testing. In this example, the module 230 instruments the example code to observe the number of times the subroutine gc_hmac_sha1 is called during testing. In this example, the test capture module 238 causes an indication that the subroutine has been stored 325 times to be stored in the runtime observations module 240. In this example, test capture module 238 causes an indication to be stored in the runtime observations module 240 that the following specific portion of the code-under-test have been tested: call of function gc_hmac_sha 1 has been called 325 times during the tests.

FIG. 10D is an illustrative drawing of the example code with annotations to indicate that a particular object has been allocated and then freed up some number of times in the course of testing. In this example, the module 230 instruments the example code to observe the number of times the object tmp is allocated and then freed during testing. It will be appreciated, for example, that an object may be allocated and freed in memory on a heap or in a stack, for example. In this example, the test capture module 238 causes an indication that the object has been allocated and freed 42 times to be stored in the runtime observations module 240. In this example, test capture module 238 causes an indication to be stored in the runtime observations module 240 that the following specific portion of the code-under-test have been tested: variable tmp is allocated and then freed 42 times during the given execution intervals during test execution.

Examples—Static Analysis

FIGS. 11A-11F are illustrative drawings showing the example source code annotated to indicate checker tests performed by the static analysis module 212 of FIG. 2 in accordance with some embodiments. Static analysis results 220 generated by the static analysis module 212 can be used to generate one or more of the STA filter elements 604-610 of FIG. 6, for example. filters 314-314-5. For example, static analysis results may provide information that indicates which code is untestable or not worthy of testing, and therefore, ought to be omitted from the test coverage. Conversely, static analysis results also may provide information that indicates additional code that ought to be tested, and therefore, ought to be included in the testing efforts.

FIG. 11A is an illustrative drawing of the example code with annotations to indicate that a particular code path indicates an error condition that would result in termination of execution. Code having this kind of effect on execution of a program often is referred to as being a ‘dead-end execution path’ or a ‘killpath’. In this particular example, assume that the specification 254 is used to communicate a directive to the static analysis module 212 directing it to use a static analysis tool checker program that identifies a killpath that includes the example code, assert (0). In accordance with some embodiments, the code that includes assert (0) and that is identified to be dead end code is communicated to the test analysis module 224, and code filter generation module 302, generates a STA filter element (e.g., one of the filters 606 to 610) to omit (i.e. filter out) or include (filter in) that code from testing or include (i.e. filter in) that code to testing.

FIG. 11B is an illustrative drawing of the example code with annotations to indicate that particular code that is ‘dead code’. In this example, assume that the specification 254 is used to communicate a directive to the static analysis module 212 use a checker program that determines that if the variable “u” in the example code can never have value “l”, then the code in the then-branch condition can never be executed, and therefore, it is dead code. In other words, code dependent upon “u” having the value “l” can never execute, and therefore, that code is dead code. In accordance with some embodiments, the code determined to include the dead end code is communicated to the test analysis module 224, and code filter generation module 302, generates a STA filter element (e.g., one of the filters 606 to 610) so as to omit that code from testing or to include that code in testing.

FIG. 11C is an illustrative drawing of the example code with annotations to indicate that a static call graph in which a function can call be called in two locations within another function. In this example, assume that the specification 254 is used to communicate a directive to the static analysis module 212 to use a checker that determines that the function gc_hmac_sha1 within the example code could be called by function gc_pbkdf2_sha1 in two locations. In accordance with some embodiments, the code, which is determined to be static call graph code relating to both calls to the function gc_hmac_sha1, is communicated to the test analysis module 224, and code filter generation module 302, generates a STA filter element (e.g., filter 604) so as to include that code within testing.

FIG. 11D is an illustrative drawing of the example code with annotations to indicate that a change in a function in one part of the example code has an impact upon a function elsewhere in other code. Assume in this example that the behavior of the function gc_pbkdf2_sha1 has been changed by a change of the behavior of function gc_hmac_sha1 due to the function call on line 25 of the example code. Further assume in this example, that the specification 254 is used to communicate a directive to the static analysis module 212 to use a checker that can identify changes in code such as a function, header, type or global variable in one part of the code that can have an impact in another part of the code. In accordance with some embodiments, the second static analysis results 220 produced by the static analysis module 212 would indicate that other code such as the function gc_pbkdf2_sha1 could be impacted by a change in the gc_hmac_sha1. In accordance with some embodiments, code of other functions located elsewhere in the code that call the changed function gc_pbkdf2_sha1 and that could be impacted by a change in that function are communicated to the test analysis module 224, and code filter generation module 302, generates a STA filter element (e.g., filter 604) so as to include those other functions within testing. In other words, an SA filter produced in response to identification of code that could be impacted by a change in some other code, the gc_hmac_sha1 code in this example, results in code from the AST 210 that matches the identified potentially impacted code being included in testing, other functions located elsewhere in the code that call the changed function gc_pbkdf2_sha1. Commonly owned U.S. Patent Application Ser. No. 61/706,819, filed Sep. 28, 2012, Change Impact Analysis, discloses a method and apparatus for change impact analysis, which is expressly incorporated herein by this reference.

FIG. 11E is an illustrative drawing of the example code with annotations to indicate that a part of the example code that has been examined for a particular syntactical construct. In this example the syntactical construct “if (c==0)” indicates that the variable “c” is an input parameter. As a general rule, input parameters must be tested. Assume that the specification 254 is used to communicate a directive to the static analysis module 212 to use a checker that can identify input parameters that should be tested. In accordance with some embodiments, the code that includes the input parameter c is communicated to the test analysis module 224, and code filter generation module 302, generates a STA filter element (e.g., filter 604) so as to include that code within testing. In other words, an STA filter element filter produced in response to the checker that identifies code that includes the input parameter c in code from the AST 210 that matches the identified static call graph codes being included in testing.

FIG. 11F is an illustrative drawing of the example code with annotations to indicate another part of the example code that has been examined for a particular syntactical construct. In this example the syntactical construct indicates that the code is debug code that does not require testing. Assume that the specification 254 is used to communicate a directive to the static analysis module 212 to use a checker that can identify debug code that does not require testing. In accordance with some embodiments, the debug code is communicated to the test analysis module 224, and code filter generation module 302, generates a STA filter element (e.g., one of the filters 606-610) so as to include or exclude that code from testing.

FIG. 12 is an illustrative drawing showing two example test policies in accordance with some embodiments. Test specification policy 1202 requires testing of all aspects of new code developed, changed or added to since Jan. 1, 2012. Test specification policy 1204 requires testing of all function returns and is not limited by date.

FIG. 13 is an illustrative graph representing in conceptual terms a relationship between percentage code tested versus effort to develop tests to test the code. It will be appreciated from the graph that as a higher and higher percentages of the code are tested, the effort required to create additional tests to test the remaining untested code increases. Thus, in general, after some level of testing has been completed there is a diminishing test benefit return with increased test effort. Thus, it is advantageous to identify portions of code that need not be tested so as to not waste effort attempting to test that code. For example, it can be a waste of effort to attempt to test code that is not testable (e.g., unreachable code statements or dead end code). Also, not all tested code adds equal value to the testing. For example, testing non-critical code such as debug code, legacy code or exception handling code may not be a good use of testing resources. It will be appreciated that the embodiments disclosed herein identify code that is to be excluded from testing so as to improve test development efficiency by avoiding unnecessary tests. The embodiments disclosed herein also identify code that might have been overlooked for testing, such as code that is susceptible to change impact as a result of changes in other code, for example.

Moreover, the portion of computer program code to be subject to testing can be specified using a test specification that can be created by a user. In some embodiments, the test specification provides SCM parameters, for example, used to identify code from an SCM that should be included or excluded in dynamic testing. In some embodiments, the test specification also provides SA parameters, for example, used to run static analyses to identify code that should be included or excluded in dynamic testing. The identified code is used to modify the computer program code generate modified code to compare with dynamic test results to evaluate the dynamic test results.

Hardware Environment

FIG. 14 shows a diagrammatic representation of a machine in the example form of a computer system 1400 within which a set of instructions, for causing the machine to perform any one or more of the methodologies discussed herein, may be executed. The computer system 1400 can comprise, for example, can be configured to implement a static analysis tool and a dynamic analysis tool, for example. In alternative embodiments, the machine operates as a standalone device or may be connected (e.g., networked) to other machines. In a networked deployment, the machine may operate in the capacity of a server or a client machine in server-client network environment, or as a peer machine in a peer-to-peer (or distributed) network environment. The machine may be a server computer, a client computer, a personal computer (PC), a tablet PC, a set-top box (STB), a Personal Digital Assistant (PDA), a cellular telephone, a web appliance, a network router, switch or bridge, or any machine capable of executing a set of instructions (sequential or otherwise) that specify actions to be taken by that machine. Further, while only a single machine is illustrated, the term “machine” shall also be taken to include any collection of machines that individually or jointly execute a set (or multiple sets) of instructions to perform any one or more of the methodologies discussed herein.

The example computer system 1400 includes a processor 1402 (e.g., a central processing unit (CPU), a graphics processing unit (GPU), or both), a main memory 1404 and a static memory 1406, which communicate with each other via a bus 1408. The computer system 1400 may further include a video display unit 1410 (e.g., liquid crystal display (LCD), organic light emitting diode (OLED) display, touch screen, or a cathode ray tube (CRT), for example. The computer system 1400 also includes an alphanumeric input device 1412 (e.g., a keyboard, a physical keyboard, a virtual keyboard using software), a cursor control device or input sensor 1414 (e.g., a mouse, a trackpad, a trackball, a sensor or reader, a machine readable information reader, bar code reader), a disk drive unit 1416, a signal generation device 1418 (e.g., a speaker) and a network interface device or transceiver 1420.

The disk drive unit 1416 includes a non-transitory machine-readable storage device medium 1422 on which is stored one or more sets of instructions (e.g., software 1424) embodying any one or more of the methodologies or functions described herein, such as the processes of FIGS. 2-5B. The software 1424 may also reside, completely or at least partially, within the main memory 1404 and/or within the processor 1402 during execution thereof by the computer system 1400, the main memory 1404 and the processor 1402 also constituting non-transitory machine-readable storage device media. The non-transitory machine-readable storage device medium 1422 also can store an integrated circuit design.

The instructions 1424 may further be transmitted or received over a network 1426 via the network interface device 1420.

While the machine-readable medium 1422 is shown in an example embodiment to be a single medium, the term “machine-readable medium,” “computer readable medium,” and the like should be taken to include a single medium or multiple media (e.g., a centralized or distributed database, and/or associated caches and servers) that store the one or more sets of instructions. The term “machine-readable medium” shall also be taken to include any medium that is capable of storing, encoding or carrying a set of instructions for execution by the machine and that cause the machine to perform any one or more of the methodologies of the present disclosure. The term “machine-readable medium” shall accordingly be taken to include, but not be limited to, solid-state memories, optical and magnetic media, and carrier wave signals.

It will be appreciated that, for clarity purposes, the above description describes some embodiments with reference to different functional units or processors. However, it will be apparent that any suitable distribution of functionality between different functional units, processors or domains may be used without detracting from the present disclosure. For example, functionality illustrated to be performed by separate processors or controllers may be performed by the same processor or controller. Hence, references to specific functional units are only to be seen as references to suitable means for providing the described functionality, rather than indicative of a strict logical or physical structure or organization.

Certain embodiments described herein may be implemented as logic or a number of modules, engines, components, or mechanisms. A module, engine, logic, component, or mechanism (collectively referred to as a “module”) may be a tangible unit capable of performing certain operations and configured or arranged in a certain manner. In certain example embodiments, one or more computer systems (e.g., a standalone, client, or server computer system) or one or more components of a computer system (e.g., a processor or a group of processors) may be configured by software (e.g., an application or application portion) or firmware (note that software and firmware can generally be used interchangeably herein as is known by a skilled artisan) as a module that operates to perform certain operations described herein.

In various embodiments, a module may be implemented mechanically or electronically. For example, a module may comprise dedicated circuitry or logic that is permanently configured (e.g., within a special-purpose processor, application specific integrated circuit (ASIC), or array) to perform certain operations. A module may also comprise programmable logic or circuitry (e.g., as encompassed within a general-purpose processor or other programmable processor) that is temporarily configured by software or firmware to perform certain operations. It will be appreciated that a decision to implement a module mechanically, in dedicated and permanently configured circuitry, or in temporarily configured circuitry (e.g., configured by software) may be driven by, for example, cost, time, energy-usage, and package size considerations.

Accordingly, the term “module” should be understood to encompass a tangible entity, be that an entity that is physically constructed, permanently configured (e.g., hardwired), or temporarily configured (e.g., programmed) to operate in a certain manner or to perform certain operations described herein. Considering embodiments in which modules or components are temporarily configured (e.g., programmed), each of the modules or components need not be configured or instantiated at any one instance in time. For example, where the modules or components comprise a general-purpose processor configured using software, the general-purpose processor may be configured as respective different modules at different times. Software may accordingly configure the processor to constitute a particular module at one instance of time and to constitute a different module at a different instance of time.

Modules can provide information to, and receive information from, other modules. Accordingly, the described modules may be regarded as being communicatively coupled. Where multiples of such modules exist contemporaneously, communications may be achieved through signal transmission (e.g., over appropriate circuits and buses) that connect the modules. In embodiments in which multiple modules are configured or instantiated at different times, communications between such modules may be achieved, for example, through the storage and retrieval of information in memory structures to which the multiple modules have access. For example, one module may perform an operation and store the output of that operation in a memory device to which it is communicatively coupled. A further module may then, at a later time, access the memory device to retrieve and process the stored output. Modules may also initiate communications with input or output devices and can operate on a resource (e.g., a collection of information).

Although the present disclosure has been described in connection with some embodiments, it is not intended to be limited to the specific form set forth herein. One skilled in the art would recognize that various features of the described embodiments may be combined in accordance with the present disclosure. Moreover, it will be appreciated that various modifications and alterations may be made by those skilled in the art without departing from the spirit and scope of the present disclosure.

In addition, in the foregoing Detailed Description, it can be seen that various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments require more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive subject matter lies in less than all features of a single disclosed embodiment. Thus the following claims are hereby incorporated into the Detailed Description, with each claim standing on its own as a separate embodiment.

The foregoing description and drawings of embodiments in accordance with the present invention are merely illustrative of the principles of the invention. Therefore, it will be understood that various modifications can be made to the embodiments by those skilled in the art without departing from the spirit and scope of the invention, which is defined in the appended claims. 

The invention claimed is:
 1. A method comprising: demarcating, by at least one computer processor, a plurality of code portions as a function of time, with respect to a predetermined time period; evaluating, by the at least one computer processor, a result of a dynamic test, wherein the dynamic test comprises an automated runtime observation; filtering, by the at least one computer processor, the plurality of code portions, by automatically identifying a first code portion to omit from testing via a filter generated in accordance with a test policy specification, based at least in part on the automated runtime observation, and based at least in part on a determination of whether the runtime observation occurs in a range of time with respect to the predetermined time period; testing, by the at least one computer processor, a second code portion of the plurality of code portions, using the dynamic test; capturing, by the at least one computer processor, a test result indicating at least the second code portion, tested using the dynamic test; identifying, by the at least one computer processor, a subset of the plurality of code portions to check, by the at least one computer processor, in an abstract syntax tree (AST) representing a conditional branch code path, wherein the AST is a result of a static analysis of the subset of the plurality of code portions; determining, by the at least one computer processor, adequacy of the test result based at least in part on the runtime observation, based at least in part on checking the identified subset of the plurality of code portions in the AST, and based at least in part on analyzing output resulting from conditional execution of a code statement corresponding to at least the first code portion or the second code portion; and outputting, by the at least one computer processor, an indication of whether the dynamic test meets a requirement, based on the determined adequacy of the test result.
 2. The method of claim 1, wherein the subset of the plurality of code portions is determined by identifying a plurality of lines of code.
 3. The method of claim 1, wherein the subset of the plurality of code portions is determined by identifying specific values of code variables.
 4. The method of claim 1, wherein the subset of the plurality of code portions is determined by identifying a specific sequence of code statements.
 5. The method of claim 1, wherein the subset of the plurality of code portions is determined by one or more functions within the plurality of code portions.
 6. The method of claim 1, wherein the test result comprises a conditional execution sequence.
 7. The method of claim 1, further comprising: using static analysis of the plurality of code portions to identify the subset of the plurality of code portions to include in the dynamic test.
 8. A system comprising memory and at least one processor configured to: demarcate a plurality of code portions as a function of time, with respect to a predetermined time period; evaluate a result of a dynamic test, wherein the dynamic test comprises an automated runtime observation; filter the plurality of code portions, by automatically identifying a first code portion to omit from testing via a filter generated in accordance with a test policy specification, based at least in part on the automated runtime observation, and based at least in part on a determination of whether the runtime observation occurs in a range of time with respect to the predetermined time period; test a second code portion of the plurality of code portions, using the dynamic test; capture a test result indicating at least the second code portion, tested using the dynamic test; identify a subset of the plurality of code portions to check in an abstract syntax tree (AST) representing a conditional branch code path, wherein the AST is a result of a static analysis of the subset of the plurality of code portions; determine adequacy of the test result based at least in part on the runtime observation, based at least in part on checking the identified subset of the plurality of code portions in the AST, and based at least in part on analyzing output resulting from conditional execution of a code statement corresponding to at least the first code portion or the second code portion; and output an indication of whether the dynamic test meets a requirement, based on the determined adequacy of the test result.
 9. The system of claim 8, wherein the subset of the plurality of code portions is determined by identifying specific values of code variables.
 10. The system of claim 8, wherein the subset of the plurality of code portions is determined by identifying a specific sequence of code statements.
 11. The system of claim 8, wherein the subset of the plurality of code portions is determined by one or more functions within the plurality of code portions.
 12. The system of claim 8, wherein the test result comprises a conditional execution sequence.
 13. The system of claim 8, the at least one processor further configured to: use static analysis of the plurality of code portions to identify the subset of the plurality of code portions to include in the dynamic test.
 14. A non-transitory machine-readable storage device medium comprising instructions that, when executed by at least one processor, cause the at least one processor to perform operations comprising: demarcating a plurality of code portions as a function of time, with respect to a predetermined time period; evaluating a result of a dynamic test, wherein the dynamic test comprises an automated runtime observation; filtering the plurality of code portions, by automatically identifying a first code portion to omit from testing via a filter generated in accordance with a test policy specification, based at least in part on the automated runtime observation, and based at least in part on a determination of whether the runtime observation occurs in a range of time with respect to the predetermined time period; testing a second code portion of the plurality of code portions, using the dynamic test; capturing a test result indicating at least the second code portion, tested using the dynamic test; identifying a subset of the plurality of code portions to check in an abstract syntax tree (AST) representing a conditional branch code path, wherein the AST is a result of a static analysis of the subset of the plurality of code portions; determining adequacy of the test result based at least in part on the runtime observation, based at least in part on checking the identified subset of the plurality of code portions in the AST, and based at least in part on analyzing output resulting from conditional execution of a code statement corresponding to at least the first code portion or the second code portion; and outputting an indication of whether the dynamic test meets a requirement, based on the determined adequacy of the test result.
 15. The non-transitory machine-readable storage device medium of claim 14, wherein the subset of the plurality of code portions is determined by identifying a plurality of lines of code.
 16. The non-transitory machine-readable storage device medium of claim 14, wherein the subset of the plurality of code portions is determined by identifying specific values of code variables.
 17. The non-transitory machine-readable storage device medium of claim 14, wherein the subset of the plurality of code portions is determined by identifying a specific sequence of code statements.
 18. The non-transitory machine-readable storage device medium of claim 14, wherein the subset of the plurality of code portions is determined by one or more functions within the plurality of code portions.
 19. The non-transitory machine-readable storage device medium of claim 14, wherein the test result comprises a conditional execution sequence.
 20. The non-transitory machine-readable storage device medium of claim 14, the operations further comprising: using static analysis of the plurality of code portions to identify the subset of the plurality of code portions to include in the dynamic test. 